// 车险加载表单
import { deepCopy } from '@/utils/tools'

let map = {

    // 申请计费
    // postMq: '',
 
    // 
    postReview: ['carSubmitExamine'],

    // 核保
    reviewOrder: ['carExaminePass', 'carExamineReject'],

    // 缴费
    // paying: '',
    
    // 申请支付
    submitPay: [ 'carSubmitPlay' ],

    // 支付审核
    payPass: ['carExaminePlay'],

    // 支付确认
    alreadyPay: ['carAlreadyPaid'],
    
    // 刷出金额 ( 确认缴费 )
    setPaid: ['carAlreadyPaid'],

    // 集印
    makeSoftPrint: ['carIndia'],

    // 打单
    makePrinting: ['carIntimidate'],

    // 转业务
    setArchived: ['carTransitionBusiness']
    
}

export default (powerConf, data):any =>{

    data  = deepCopy(data);
    
    let keys = [];

    Object.keys(map).forEach(key =>{

        if(!powerConf[key]){
           keys = [...keys, ...map[key]]
        }
        
    })

    let keyStore = new Set(keys)

    data.forEach(item =>{

        let cache = []

        item['formBtns'].forEach(btnName =>{

            if(!keyStore.has(btnName)){
                cache.push(btnName)
            }
            
        })

        item['formBtns']  = cache
        
    })
    

    return data

}